package com.miyu.system.controller.sys;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.miyu.common.pojo.cos.CosSpace;
import com.miyu.system.service.sys.CosMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 菜单处理类菜单
 *
 * @author MIYU
 * @date 2022/05/14
 */
@RestController
@RequestMapping("/system/menu")
public class CosMenu {

    @Autowired
    private CosMenuService cosMenuService;
    /**
     * 菜单取值以及权限菜单
     * @return
     */
    @RequestMapping("querySysMenu")
    public JSONArray querySysMenu(){
        JSONArray rs = cosMenuService.querySysMenu();
        return rs;
    }

    /**
     * 把菜单dict类型
     *
     * @return {@code JSONArray}
     */
    @RequestMapping("getMenuDict")
    public JSONArray getMenuDict(@RequestBody JSONObject param){
        JSONArray rs = cosMenuService.getMenuDict(param);
        return rs;
    }

    /**
     * 菜单添加修改
     * @param param
     * @return
     */
    @RequestMapping("saveCosMenu")
    public JSONObject saveOrUpdateSysMenu(@RequestBody JSONObject param){
        JSONObject rs = cosMenuService.SaveOrUpdateSysMenu(param);
        return rs;
    }
    /**
     * 菜单删除
     * @param param
     * @return
     */
    @RequestMapping("delCosMenu")
    public JSONObject delCosMenu(@RequestBody JSONObject param){
        JSONObject rs = cosMenuService.delCosMenu(param);
        return rs;
    }

    /**
     * 作用域空间列表
     *
     * @return {@code List<CosSpace>}
     */
    @RequestMapping("getCosSpaceList")
    public List<CosSpace> getCosSpaceList() {
        List<CosSpace> list = cosMenuService.getCosSpaceList();
        return list;
    }

}
